'use client'

import { User } from '@supabase/supabase-js'
import { useEffect } from 'react'

import { useUserStore } from '@/store/UserStore'

import { Footer } from './Footer'
import { Header } from './Header'
import SideBar from './SideBar'
export function AuthLayout({
  user,
  children,
}: {
  user: User
  children: React.ReactNode
}) {
  const setUser = useUserStore(state => state.setUser)

  useEffect(() => {
    setUser(user)
  }, [user, setUser])

  return (
    <div className="flex h-screen">
      <SideBar />
      <div className="flex-1 flex flex-col bg-card">
        <Header />
        <main className="flex-1">{children}</main>
        <Footer />
      </div>
    </div>
  )
}
